﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using DevExpress.Web.ASPxGridView;
using System.Configuration;

public partial class Teacher_Award : System.Web.UI.Page
{
    SqlConnection conn;
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Institte_of_Fine_ArtsConnectionString"].ConnectionString);
    }
    protected bool CheckExistStudent(string AwardID)
    {
        conn.Open();
        SqlCommand comm = new SqlCommand();
        comm.CommandText = "SELECT AwardID FROM Award WHERE AwardID=" + AwardID;
        comm.CommandType = System.Data.CommandType.Text;
        comm.Connection = conn;
        SqlDataReader read = comm.ExecuteReader();
        if (read.HasRows != null)
        {
            return false;
        }
        return true;
    }
    protected void gvwAward_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
    {
        if (e.NewValues["Award_Name"] == null)
        {
            AddError(e.Errors, gvwAward.Columns["Award_Name"], "Award name can't be null.");
        }
        if (e.NewValues["Awrad_Details"] == null)
        {
            AddError(e.Errors, gvwAward.Columns["Awrad_Details"], "Award details can't be null.");
        }
    }
    void AddError(Dictionary<GridViewColumn, string> errors, GridViewColumn column, string errorText)
    {
        if (errors.ContainsKey(column)) return;
        errors[column] = errorText;
    }
}